<template>
	<view class="padding-30">
		<view class="initialShare-list">
			<view class="initialShare-item" v-for="(item,index) in list" :key="index">
				<image class="initialShare-item-image" :src="item.image" mode=""></image>
				<view class="padding-30">
					<view class="initialShare-item-center">
						<view class="initialShare-title-box" v-for="(item1,index1) in item.titleList" :key="index1">
							<view style="font-size: 16px;padding-bottom: 10rpx;">
								{{item1.title}}
							</view>
							<view>
								{{item1.number}}
							</view>
						</view>
					</view>
					<view class="initialShare-item-bottom">
						<view>认购金额 {{item.price}}元</view>
						<button-round name="认购" fontSize="12px" borderRadius="10rpx" @click="goToPay(item)"></button-round>
					</view>
				</view>
			</view>
		</view>
		<!-- 实名认证弹窗 -->
		<popup-view :popupObject="popupObject1" :popShow="show1" @clickShow="popUpViewShow1"></popup-view>
	</view>
</template>

<script>
	import buttonRound from "@/components/button/button-round.vue"
	import popupView from "@/components/popup/popup-view.vue"
	export default {
		components: {
			buttonRound,
			popupView
		},
		data() {
			return {
				list: [],
				type: '',
				show1: false,
				popupObject1:{
					title:'请完成',
					desc:'实名认证',
					btn:'去认证',
					tips:''
				},
				userInfo:{}
			}
		},
		onLoad(option) {
			this.type = option.id
			uni.setNavigationBarTitle({
				title: option.name
			})
		},
		onShow() {
			this.getInitialList()
			this.getUserInfo()
		},
		methods: {
			getUserInfo() {
				this.$http.post(this.$api.getUserInfo, {}, {
					token: true
				}).then(res => {
					this.userInfo = res.data
				})
			},
			popUpViewShow1(status){
				this.show1 = status
				this.$tools.navigateTo('/pages/index/index-list/real-name')
			},
			getInitialList() {
				this.$http.post(this.$api.getInitialList, {
					type: this.type
				}, {
					token: true
				}).then(res => {
					if (res.code == 1) {
						this.list = res.data.map(item => {
							return {
								id:item.id,
								image: item.img,
								titleList: [{
										title: '持股',
										number: item.sharehold + '股'
									},
									{
										title: '每日收益分红',
										number: item.income + '元'
									},
									{
										title: '收益周期',
										number: item.income_day + '天'
									},
								],
								price: item.amount,
							}
						})
					}
				})
			},
			goToPay(item) {
				// 判断是否实名认证
				if(this.userInfo.is_auth !== 1){
					return this.show1 = true
				}
				let form={
					order_type:2,
					type:2,
					initial_id:item.id
				}
				this.$tools.navigateTo('/pages/pay/pay?form='+ JSON.stringify(form))
			}
		}
	}
</script>

<style lang="scss">
	.initialShare-title-box {
		display: flex;
		align-items: center;
		flex-direction: column;
		justify-content: center;
	}

	.initialShare-item {
		background-color: #FFF0CA;
		border-radius: 20rpx;
		margin-bottom: 30rpx;
		overflow: hidden;
	}

	.initialShare-item-image {
		width: 100%;
		height: 300rpx;
	}

	.initialShare-item-center {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0rpx 30rpx 30rpx 30rpx;
		border-bottom: 2rpx solid #EEDFB9;
	}

	.initialShare-item-bottom {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding-top: 30rpx;
	}
</style>